#!/usr/bin/node

const https = require('http'),
      log = console.log,
      url = require('url'),
      addr = 'http://www.sian.com/';

let opt =(addr)=>{
  let p = url.parse(addr);
  p.headers = {
    'user-aget':'curl/7.29.0'
  };
  return p;
};
get(addr);

function get(addr){
  https.get(opt(addr),(res)=>{
    log(res.headers);
    if(res.statusCode>=300&&res.statusCode<400){
      get(res.headers.location);
    }else{
      res.pipe(process.stdout);
    }
  })
}

